const chatApp = window.chatApp;
chatApp.login();
document.getElementById("login-btn")
    .onclick = function() {
        var username = document.getElementById("username").value;
        var password = document.getElementById("password").value;
        doLogin(username, password);
    }

// function doLogin(username, password) {
//     $.ajax({
//         url: "login.php",
//         type: "post",
//         data: "username=" + username + "&password=" + password
//     }).then((ret) => {
//         alert(ret);
//     }, (err) => {
//         alert("error:" + err);
//         console.log(err);
//     });
// }

function doLogin(username, password) {
    $.ajax({
        url: "login.php",
        type: "post",
        contentType: "application/json",
        data: JSON.stringify({
            username: username,
            password: password
        }),
        dataType: "json"
    }).then(function(userInfo) {
        document.getElementById("face").src = userInfo.face;
        chatApp.showMain();
        document.getElementById("send.btn").onclick = doSend;
    }, (err) => {
        alert("error:" + err);
        console.log(err);
    });
}
debugger;

function doSend(){
    var content =document.getElementById
    ("message.input").value;
    var data = {
        content:content,senderId:currentUser.userId
    };
    $.ajax({
        url:"send.php,type:"post",data
    })
}

function pulldata(){
    setInterval((
        
    ))
}